package com.ebelter.seneo.ui.fragments.infos;


import android.graphics.Color;
import android.os.Bundle;
import android.widget.TextView;

import com.ebelter.btcomlib.models.db.products.seneo.SeneoUserCurrentMeasureRecord;
import com.ebelter.btcomlib.models.db.products.seneo.SeneoUserinfos;
import com.ebelter.btcomlib.utils.NumUtils;
import com.ebelter.btcomlib.utils.ViewUtils;
import com.ebelter.seneo.R;
import com.ebelter.seneo.contants.IUserContant;
import com.ebelter.seneo.ui.fragments.BaseFragment;
import com.ebelter.seneo.ui.fragments.main.Info_Fragment;
import com.ebelter.seneo.ui.views.LevelView;


//填写密码
public class Info_BodyAge_Fragment extends BaseFragment  implements Info_Fragment.IInfoUpdateInterface {

    public static final String TAG = "Info_BodyAge_Fragment";
    TextView infofly_value_tv;
    TextView infofly_valueunit_tv;
    TextView infofly_tip1_tv;
    LevelView info_levelview;

    @Override
    protected int setLayoutResouceId() {
        return R.layout.info_fly1;
    }

    @Override
    protected void initView() {
        FV();
    }

    private void FV() {
        infofly_value_tv=findViewById(R.id.infofly_value_tv);
        infofly_valueunit_tv=findViewById(R.id.infofly_valueunit_tv);
        infofly_tip1_tv=findViewById(R.id.infofly_tip1_tv);
        info_levelview=findViewById(R.id.info_levelview);
        infofly_valueunit_tv.setText("years old");
    }


    @Override
    protected void initData(Bundle arguments) {

        String tip=getString(R.string.str_Physical_age_introduce);
        infofly_tip1_tv.setText(tip);

        //执行了这一句 下面的UpdateCurrentMesureInfo接口会回调display方法
        if (getParentFragment()!=null){
            ((Info_Fragment)getParentFragment()).getCurrentDisplayInfo(TAG);
        }
    }



    @Override
    public void UpdateCurrentMesureInfo(SeneoUserinfos currentUserinfos, SeneoUserCurrentMeasureRecord currentMeasureRecord) {

        disBodyAge(currentUserinfos,currentMeasureRecord);
    }

    private void disBodyAge(SeneoUserinfos currentUserinfos, SeneoUserCurrentMeasureRecord currentMeasureRecord) {
        if (currentMeasureRecord!=null){
            if (currentMeasureRecord.bodyAge!=0){
                ViewUtils.setTextViewStr(infofly_value_tv, NumUtils.numBaoLiuWei0(currentMeasureRecord.bodyAge)+"");
            }else if (currentMeasureRecord.bodyAge == 0){
                ViewUtils.setTextViewStr(infofly_value_tv, IUserContant.IDIS.Non);
            }

        }else {
            ViewUtils.setTextViewStr(infofly_value_tv, IUserContant.IDIS.Non);
        }
    }
}
